<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            width: 100px;
            height: 100px;
            background-color: red;
            border-radius: 100%;
            position: absolute;
        }
    </style>
</head>
<body>

    <div id="box"></div>
    <script>


        // setInterval(() =>{
        //     console.log(1)
        // },1000)
        // let count = 0;
        // let box = document.querySelector("#box")
        // let speed = 1;
        // function time(){
        //     setTimeout(function(){
        //         box.style.left = box.offsetLeft + speed + 'px'
        //         time()
        //         count++;
        //         box.innerHTML = count;
        //     },1000)
        // }

        // time()

        let count = 0;
        let box = document.querySelector("#box")
        let speed = 1;
        function time(){
            requestAnimationFrame(function(){
                box.style.left = box.offsetLeft + speed + 'px'
                time()
                count++;
                box.innerHTML = count;
            })
        }

        time()

    </script>
</body>
</html>